/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import bean.AreaProfissional;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author VENANCIO
 */
public class AreaProfissionalDao {
    
    String sql = null;
    
    public List<AreaProfissional> getListaAreaProfissional(){
        List<AreaProfissional> listaAreaProfissional = new ArrayList<AreaProfissional>();
        
        sql = "SELECT * FROM AREA_PROFISSIONAL ORDER BY AREA_PROFISSIONAL_DESC";
        Connection con = null;
        try {
            con = new Conexao().getConexao();
            PreparedStatement stmt = con.prepareStatement(sql);
            ResultSet rs = stmt.executeQuery();
            while(rs.next()){
                AreaProfissional ap = new AreaProfissional();
                ap.setCod(rs.getInt("AREA_PROFISSIONAL_COD"));
                ap.setDescricao(rs.getString("AREA_PROFISSIONAL_DESC"));
                listaAreaProfissional.add(ap);
            }
            rs.close();
            stmt.close();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AreaProfissionalDao.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(AreaProfissionalDao.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            try {
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(AreaProfissionalDao.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        
        return listaAreaProfissional;
    }
    
}
   
